package com.supermap.search.activity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.supermap.search.R;
import com.supermap.search.Url_name;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/*这是登陆界面*/

public class LoginActivity extends AppCompatActivity {


    @BindView(R.id.et_password)
    EditText etPassword;
    @BindView(R.id.et_name)
    EditText etName;
    @BindView(R.id.bt_denglu)
    Button btDenglu;
    private SharedPreferences sp;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);

    }


    @OnClick(R.id.bt_denglu)
    public void onClick() {

        if (etName.getText().toString().trim().equals("user")||etName.getText().toString().trim().equals("master")
                ||etName.getText().toString().trim().equals("lisi")){
            if (etPassword.getText().toString().trim().equals("123")){
                //登陆了
                sp = getSharedPreferences(Url_name.SP,0);
                sp.edit().putString("name",etName.getText().toString().trim()).commit();
                sp.edit().putBoolean("state",true).commit();
                finish();
            }else {
                Toast.makeText(this, "密码错误", Toast.LENGTH_SHORT).show();
            }

        }else {
            //
            Toast.makeText(this, "账号不存在", Toast.LENGTH_SHORT).show();
        }
    }
}
